package com.example.networkdemo2;

import android.content.res.AssetManager;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class MainActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        ImageView image_view = findViewById(R.id.image_view);
        Glide.with(this)
                .load("https://img-operation.csdnimg.cn/csdn/silkroad/img/1702970706299.jpg")
                .into(image_view);
















        WebView webView = findViewById(R.id.webview);
        webView.setWebViewClient(new WebViewClient());
        webView.getSettings().setJavaScriptEnabled(true); // 开启js支持

        //webView.loadUrl("http://www.hnou.edu.cn"); // 加载网络地址对应的资源
        try {
            AssetManager assets = this.getAssets();
            InputStream fio = assets.open("index.html");
            byte[] b = new byte[2048];
            int len = fio.read(b);
            String s = new String(b,0,len);
            String html = s;
            webView.loadData(html,"text/html","utf-8");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}